package com.example.administrator.shihuo.activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.RadioGroup;

import com.example.administrator.shihuo.R;
import com.example.administrator.shihuo.fragments.MyFragment;
import com.example.administrator.shihuo.fragments.ShareCollectionsFragment;

public class MainActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener {

    private FrameLayout mainContainer;
    private RadioGroup radioGroup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        setListener();
    }

    private void initView() {
        //主布局上面的碎片容器
        mainContainer=(FrameLayout)findViewById(R.id.framelayout_mainactivity_container);
        radioGroup=(RadioGroup)findViewById(R.id.rg_mainactivity_show);
    }

    private void setListener() {
        radioGroup.setOnCheckedChangeListener(this);
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId){

            case R.id.rb_mainactivity_firstpage:

                break;
            case R.id.rb_mainactivity_haitao:

                break;
            case R.id.rb_mainactivity_shaiwu:
                getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_mainactivity_container, new ShareCollectionsFragment()).commit();
                break;
            case R.id.rb_mainactivity_discover:

                break;
            case R.id.rb_mainactivity_mine:
                getSupportFragmentManager().beginTransaction().replace(R.id.framelayout_mainactivity_container, new MyFragment()).commit();
                break;
            default:
                break;
        }
    }
}
